package com.example.mobile2121606109ycg0505;

import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private EditText edtTxtMainUserName;
    private EditText edtTxtMainPassword;
    private Button btnMainLogin;
    private Button btnMainRegister;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        initView();
    }

    private void initView() {
        edtTxtMainUserName = (EditText) findViewById(R.id.edtTxtMainUserName);
        edtTxtMainPassword = (EditText) findViewById(R.id.edtTxtMainPassword);
        btnMainLogin = (Button) findViewById(R.id.btnMainLogin);
        btnMainRegister = (Button) findViewById(R.id.btnMainRegister);
        btnMainLogin.setOnClickListener(this);
        btnMainRegister.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.btnMainLogin:
                if (edtTxtMainUserName.getText().toString().equals("admin")&
                edtTxtMainPassword.getText().toString().equals("123456"))
                    new AlertDialog.Builder(this)
                            .setTitle("登录信息")
                    .setMessage("登录成功")
                    .setPositiveButton("确定",null)
                    .create()
                    .show();
                break;
            case R.id.btnMainRegister:
                Intent intent =new Intent(this, RegisterActivity.class);
                startActivity(intent);
                break;
        }
    }
}